package work;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.util.Scanner;

public class homework {
    public static void main(String[] args) {
        T t = new T();
        S s = new S(t);
        t.start();
        new Thread(s).start();
    }
}


class T extends Thread {
    private boolean loop = true;

    public void setLoop(boolean loop) {
        this.loop = loop;
    }

    @Override
    public void run() {
        while (loop) {
            System.out.println((int) (Math.random() * 101));
            try {
                Thread.sleep(500);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

class S implements Runnable {
    T t = null;
    Scanner scanner = new Scanner(System.in);

    public S(T t) {
        this.t = t;
    }

    @Override
    public void run() {
        while (true) {
            char str = scanner.next().toUpperCase().charAt(0);
            if (str == 'Q') {
                t.setLoop(false);
                break;
            }
        }
    }


}